import 'package:flutter/material.dart'; 

import '../pages/Tabs.dart';
import '../pages/product_list.dart';
import '../pages/search.dart';
import '../pages/product_content.dart';
import '../pages/tabs/cart.dart';
import '../pages/login.dart';
import '../pages/register/register_first.dart';
import '../pages/register/register_second.dart';
import '../pages/register/register_third.dart';
import '../pages/checkout.dart';
import '../pages/address/address_add.dart';
import '../pages/address/address_edit.dart';
import '../pages/address/address_list.dart';
import '../pages/pay.dart';
import '../pages/order.dart';
import '../pages/order_info.dart';

//配置路由 
final routes = { 
  '/':(context)=>Tabs(), 
  '/search': (context) => SearchPage(),
  '/cart': (context) => CartPage(),
  '/login': (context) => LoginPage(),
  '/checkout': (context) => CheckOutPage(),
  '/registerFirst': (context) => RegisterFirst(),
  '/addressAdd': (context) => AddressAddPage(),
  '/addressEdit': (context, {arguments}) => AddressEditPage(arguments: arguments),
  '/addressList': (context) => AddressListPage(),
  '/registerSecond': (context, {arguments}) => RegisterSecond(arguments: arguments),
  '/registerThird': (context, {arguments}) => RegisterThird(arguments: arguments),
  '/productList': (context, {arguments}) => ProductListPage(arguments: arguments),
  '/productContent': (context, {arguments}) => ProductContentPage(arguments: arguments),
  '/pay': (context, {arguments}) => PayPage(arguments: arguments),
  '/order': (context) => OrderPage(),
  '/orderInfo': (context) => OrderInfoPage()
};

//固定写法 
var onGenerateRoute = (RouteSettings settings) { 
  // 统一处理 
  final String name = settings.name; 
  final Function pageContentBuilder = routes[name]; 
  if (pageContentBuilder != null) { 
    if (settings.arguments != null) { 
      final Route route = MaterialPageRoute(builder: (context) => pageContentBuilder(context, arguments: settings.arguments)); 
      return route; 
    }else{
      final Route route = MaterialPageRoute( 
        builder: (context) => pageContentBuilder(context)); return route; 
    }
  }
};